package com.example.chat_matching.controller;

import com.example.chat_matching.demo.MatchPeople;
import com.example.chat_matching.common.Result;
import com.example.chat_matching.services.MatchService;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("/match")
public class MatchController {
    @Autowired
    private MatchService matchService;
    /**
     * date: 2025/01/12 14:35<br/>
     * Description: 发起匹配请求
     * @author: jmy <br/>
     */
    @PostMapping("/newMatching")
    public Result match(@NonNull @RequestBody MatchPeople matchPeople){
        log.info(String.valueOf(matchPeople));
        return matchService.match(matchPeople);
    }

    /**
     * date: 2025/01/12 19:59<br/>
     * Description:取消匹配
     * @param sex 用户的性别
     * @param userId 用户id
     * @author: jmy <br/>
     */
    @PostMapping("/cancle")
    public Result cancleMatching(Integer sex,Integer userId){
        log.info("sex:" + sex + " userId:"+userId);
        return matchService.cancleMatch(sex,userId);
    }

    /**
     * date: 2025/01/12 21:21<br/>
     * Description:结束会话
     * @
     * @author: jmy <br/>
     */
    @PostMapping("/end")
    public Result endConversation(Integer roomId){
        log.info("roomId:" + roomId);
        return matchService.endConversation(roomId);
    }

}
